package web;

import java.util.List;

import model.League;
import model.User;
import service.LeagueService;
import service.MatchService;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Preparable;

/**
 * Class that manipulates actions of the League in web application.
 * @author Andre Melo
 * @author Marcus Leite 
 * @author Sergio Danilo
 * 
 */
public class MatchAction extends BLMSAction implements Preparable {

	private static final long serialVersionUID = 6179118877547590934L;

	//Attributes
	private Integer id;
	
	private LeagueService leagueService;
	
	private MatchService matchService;
	
	private League league;
	
	private List<League> leagues;
	
	private List<User> users;
	
	/**
	 * The main method for web application
	 * 
	 * @return Success or fail in the application
	 */
	public String main() {
		return Action.SUCCESS;
	}
	
	/**
	 * The input method
	 * @return
	 */
	public String input() {
		return Action.INPUT;
	}
	

	@Override
	public void prepare() throws Exception {
		users = userService.listAll();
		leagues = leagueService.listAll();
		
	}

	/**
	 * Return an instance of LeagueService.
	 * @return An instance of LeagueService.
	 */
	public LeagueService getLeagueService() {
		return leagueService;
	}

	/**
	 * Set an instance of LeagueService.
	 * @param leagueService An instance of LeagueService.
	 */
	public void setLeagueService(LeagueService leagueService) {
		this.leagueService = leagueService;
	}

	/**
	 * Get an instance of MatchService.
	 * @return An instance of MatchService.
	 */
	public MatchService getMatchService() {
		return matchService;
	}

	/**
	 * Set an instance of MatchService.
	 * @param matchService An instance of MatchService.
	 */
	public void setMatchService(MatchService matchService) {
		this.matchService = matchService;
	}

	/**
	 * Get a league.
	 * @return A league.
	 */
	public League getLeague() {
		return league;
	}

	/**
	 * Set a league.
	 * @param league A league.
	 */
	public void setLeague(League league) {
		this.league = league;
	}

	/**
	 * Get a list of leagues.
	 * @return A list of leagues.
	 */
	public List<League> getLeagues() {
		return leagues;
	}

	/**
	 * Set a list of leagues.
	 * @param leagues A list of leagues.
	 */
	public void setLeagues(List<League> leagues) {
		this.leagues = leagues;
	}

	/**
	 * Get a list of users.
	 * @return A list of users.
	 */
	public List<User> getUsers() {
		return users;
	}

	/**
	 * Set the list of users.
	 * @param users The list of users.
	 */
	public void setUsers(List<User> users) {
		this.users = users;
	}

	/**
	 * Get the ID of the match.
	 * @return The ID of the match.
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * Set the ID of the match.
	 * @param id The ID of the match.
	 */
	public void setId(Integer id) {
		this.id = id;
	}

}
